package com.ruoyi.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.domain.OuthouInfo;
import com.ruoyi.mes.service.IOuthouInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库信息Controller
 *
 * @author LongAndHao
 * @date 2023-04-04
 */
@Api(tags = "出库信息")
@RestController
@RequestMapping("/mes/outhou")
public class OuthouInfoController extends BaseController {
    @Autowired
    private IOuthouInfoService outhouInfoService;

    /**
     * 查询出库信息列表
     */
    @ApiOperation(value = "查询出库信息列表")
    @PreAuthorize("@ss.hasPermi('mes:outhou:list')")
    @GetMapping("/list")
    public TableDataInfo list(OuthouInfo outhouInfo) {
        startPage();
        List<OuthouInfo> list = outhouInfoService.selectOuthouInfoList(outhouInfo);
        return getDataTable(list);
    }

    /**
     * 导出出库信息列表
     */
    @ApiOperation(value = "导出出库信息列表")
    @PreAuthorize("@ss.hasPermi('mes:outhou:export')")
    @Log(title = "出库信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OuthouInfo outhouInfo) {
        List<OuthouInfo> list = outhouInfoService.selectOuthouInfoList(outhouInfo);
        ExcelUtil<OuthouInfo> util = new ExcelUtil<OuthouInfo>(OuthouInfo.class);
        util.exportExcel(response, list, "出库信息数据");
    }

    /**
     * 获取出库信息详细信息
     */
    @ApiOperation(value = "获取出库信息详细信息")
    @PreAuthorize("@ss.hasPermi('mes:outhou:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(outhouInfoService.selectOuthouInfoById(id));
    }

    /**
     * 新增出库信息
     */
    @ApiOperation(value = "新增出库信息")
    @PreAuthorize("@ss.hasPermi('mes:outhou:add')")
    @Log(title = "出库信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OuthouInfo outhouInfo) {
        return toAjax(outhouInfoService.insertOuthouInfo(outhouInfo));
    }

    /**
     * 修改出库信息
     */
    @ApiOperation(value = "修改出库信息")
    @PreAuthorize("@ss.hasPermi('mes:outhou:edit')")
    @Log(title = "出库信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OuthouInfo outhouInfo) {
        return toAjax(outhouInfoService.updateOuthouInfo(outhouInfo));
    }

    /**
     * 删除出库信息
     */
    @ApiOperation(value = "删除出库信息")
    @PreAuthorize("@ss.hasPermi('mes:outhou:remove')")
    @Log(title = "出库信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(outhouInfoService.deleteOuthouInfoByIds(ids));
    }
}
